﻿using System.Linq;
using SharpArch.Domain.DomainModel;
using SharpArch.NHibernate.Contracts.Repositories;

namespace DevelopmentKit.Extensions.SharpArch.Repositorys
{
    /// <summary>
    /// 实体仓储基础接口
    /// </summary>
    /// <typeparam name="T">实体类型</typeparam>
    /// <typeparam name="TId">实体标识类型</typeparam>
    public interface IENSRepositoryWithTypedId<T, TId> : INHibernateRepositoryWithTypedId<T, TId> where T : EntityWithTypedId<TId>
    {
        /// <summary>
        /// 获取所有实体列表查询列表
        /// </summary>
        /// <returns>查询接口</returns>
        IQueryable<T> FindAll();

        /// <summary>
        /// 获取子类 实体对象
        /// </summary>
        /// <typeparam name="TSub">子类 实体类型</typeparam>
        /// <param name="id">元素id</param>
        /// <returns>元素</returns>
        TSub Get<TSub>(TId id) where TSub : T;

        /// <summary>
        /// 获取所有子类实体列表查询列表
        /// </summary>
        /// <typeparam name="TSub">子类 实体类型</typeparam>
        /// <returns>查询接口</returns>
        IQueryable<TSub> FindAll<TSub>();

        /// <summary>
        /// 获取子类 实体对象(非立即加载)
        /// </summary>
        /// <typeparam name="TSub">子类 实体类型</typeparam>
        /// <param name="id">元素id</param>
        /// <returns>元素</returns>
        TSub Load<TSub>(TId id) where TSub : T;
    }
}